/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kmcsoft.goldshop.model.master;

import com.kmcsoft.emaster.entity.TrackableEntity;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;

/**
 *
 * @author kmcsoft02
 * set thong so trong~ parameter
 */
@PersistenceCapable(detachable = "true", table = "SHOP_PriceTradingDiamond")
public class PriceTradingDiamond extends TrackableEntity implements Comparable<PriceTradingDiamond> {

    @Persistent
    private double fromSize;
    @Persistent
    private double toSize;
    @Persistent
    private double lostPerPrice;
    @Persistent
    private boolean sell;

    public PriceTradingDiamond(double fromSize, double toSize, double lostPerPrice, boolean sell) {
        this.fromSize = fromSize;
        this.toSize = toSize;
        this.lostPerPrice = lostPerPrice;
        this.sell = sell;
    }

    public PriceTradingDiamond() {
    }

    public double getFromSize() {
        return fromSize;
    }

    public void setFromSize(double fromSize) {
        this.fromSize = fromSize;
    }

    public double getToSize() {
        return toSize;
    }

    public void setToSize(double toSize) {
        this.toSize = toSize;
    }

    public double getLostPerPrice() {
        return lostPerPrice;
    }

    public void setLostPerPrice(double lostPerPrice) {
        this.lostPerPrice = lostPerPrice;
    }

    public boolean isSell() {
        return sell;
    }

    public void setSell(boolean sell) {
        this.sell = sell;
    }

    public boolean isBuy() {
        return !sell;
    }

    public void setBuy(boolean sell) {
        this.sell = !sell;
    }

    public int compareTo(PriceTradingDiamond o) {
        if (this.fromSize < o.getFromSize()) {
            return 1;
        }
        if (this.fromSize > o.getFromSize()) {
            return -1;
        }
        return 0;
    }

    @Override
    public boolean equals(Object obj) {
        return this == obj;
    }
}
